﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
using MyBet.Helpers;

namespace MyBet
{
    public partial class ExceptionErrorDialog : ChildWindow
    {
        private string _errMsg;
        private ErrorType _errtype;


        public ErrorType Errtype
        {
            get { return _errtype; }
            set {
                BitmapImage bmi;
                _errtype = value;
                CancelButton.Visibility = Visibility.Collapsed;
                OKButton.Margin = new Thickness(153, 0, 154, 0);
                switch (_errtype)
                { 
                    case ErrorType.CriticalError:
                      bmi = new BitmapImage(new Uri(@"error.png", UriKind.Relative));
                      iconError.Source = bmi;
                      break;
                    case ErrorType.Warning:
                      bmi = new BitmapImage(new Uri(@"warning.png", UriKind.Relative));
                      iconError.Source = bmi;
                      break;
                    case ErrorType.Question:
                      bmi = new BitmapImage(new Uri(@"question.png", UriKind.Relative));
                      iconError.Source = bmi;
                      CancelButton.Visibility = Visibility.Visible;
                      OKButton.Margin = new Thickness(0, 0, 87, 0);
                      break;
                    case ErrorType.Info:
                      bmi = new BitmapImage(new Uri(@"info.png", UriKind.Relative));
                      iconError.Source = bmi;
                      break;
                }
            }
        }

        public string ErrMsg
        {
            get { return _errMsg; }
            set { _errMsg = value; lblError.Text = ErrMsg; }
        }
 
        public enum ErrorType{Info,Warning,CriticalError,Question} 


        public ExceptionErrorDialog()
        {
            InitializeComponent();
        }

        public ExceptionErrorDialog(string title, string errMsg, ErrorType errtype)
        {
            InitializeComponent();
            Errtype = errtype;
            ErrMsg = errMsg;
            Title = title;
            CancelButton.Content = LangHelper.GetString("Cancel");
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

		private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

